package com.bit.www;

import java.awt.print.PrinterException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-15
 * Time: 21:00
 */
public class Test1 {
    public static int getElement(int[] arry,int index){
        if(arry == null){
            throw new NullPointerException("传递的数组为null");

        }
        if (index<0 || index>=arry.length){
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");

        }
        return arry[index];
    }
    public static void main(String[] args) {
        int[] arr = {1,2,3};
        getElement(arr,9);//传递的数组下标越界
        System.out.println("我是其他代码");
    }
}
